package com.ruoyi.scsystem.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.scsystem.domain.SysApplication;
import com.ruoyi.scsystem.service.ISysApplicationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学分审核Controller
 * 
 * @author cai
 * @date 2022-09-19
 */
@RestController
@RequestMapping("/scsystem/application")
public class SysApplicationController extends BaseController
{
    @Autowired
    private ISysApplicationService sysApplicationService;

    /**
     * 查询学分审核列表
     */
    @PreAuthorize("@ss.hasPermi('scsystem:application:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysApplication sysApplication)
    {
        startPage();
        List<SysApplication> list = sysApplicationService.selectSysApplicationList(sysApplication);
        return getDataTable(list);
    }

    /**
     * 导出学分审核列表
     */
    @PreAuthorize("@ss.hasPermi('scsystem:application:export')")
    @Log(title = "学分审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysApplication sysApplication)
    {
        List<SysApplication> list = sysApplicationService.selectSysApplicationList(sysApplication);
        ExcelUtil<SysApplication> util = new ExcelUtil<SysApplication>(SysApplication.class);
        util.exportExcel(response, list, "学分审核数据");
    }

    /**
     * 获取学分审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('scsystem:application:query')")
    @GetMapping(value = "/{appId}")
    public AjaxResult getInfo(@PathVariable("appId") String appId)
    {
        return AjaxResult.success(sysApplicationService.selectSysApplicationByAppId(appId));
    }

    /**
     * 新增学分审核
     */
    @PreAuthorize("@ss.hasPermi('scsystem:application:add')")
    @Log(title = "学分审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysApplication sysApplication)
    {
        return toAjax(sysApplicationService.insertSysApplication(sysApplication));
    }

    /**
     * 修改学分审核
     */
    @PreAuthorize("@ss.hasPermi('scsystem:application:edit')")
    @Log(title = "学分审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysApplication sysApplication)
    {
        return toAjax(sysApplicationService.updateSysApplication(sysApplication));
    }

    /**
     * 删除学分审核
     */
    @PreAuthorize("@ss.hasPermi('scsystem:application:remove')")
    @Log(title = "学分审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{appIds}")
    public AjaxResult remove(@PathVariable String[] appIds)
    {
        return toAjax(sysApplicationService.deleteSysApplicationByAppIds(appIds));
    }
}
